/*
 * @Description:
 * @Author: Zzt
 * @Date: 2023-02-28 17:47:16
 * @LastEditTime: 2023-02-28 19:42:35
 */
import { configRequest } from '@/utils/request';
import { IPageQuery } from '@/interfaces/global';

export interface IUserParams {
  noticeUser: NoticeUser;
  notice: Notice;
}

export interface Notice {
  reason: null;
  author: string;
  createOperator: number;
  remark: null;
  noticeTypeName: string;
  title: string;
  content: string;
  publicTime: Date;
  createOperatorName: string;
  noticeTypeId: number;
  createdTime: Date;
  unitId: null;
  id: number;
  status: number;
}

export interface NoticeUser {
  unitId: null;
  id: number;
  userId: number;
  noticeId: number;
  status: number;
}

export interface ISaveNoticeUserParams {
  id?: number;
  noticeId?: number;
  status?: number;
  unitId?: number;
  userId?: number;
}
export interface IReadParams {
  id?: number;
  status?: number;
}
// 保存公告与用户关系
export function saveNoticeUser(data: ISaveNoticeUserParams) {
  return configRequest({
    url: `/notice-user`,
    method: 'post',
    data
  });
}
// 修改公告与用户关系
export function editNoticeUser(data: ISaveNoticeUserParams) {
  return configRequest({
    url: `/notice-user`,
    method: 'put',
    data
  });
}
// 分页查询公告与用户关系
export function fetchNoticeUserByPage(data: IPageQuery<ISaveNoticeUserParams>) {
  return configRequest({
    url: `/notice-user/page`,
    method: 'post',
    data
  });
}
// 根据ID查询公告与用户关系信息（已读）
export function fetchNoticeUserById(data: IReadParams) {
  return configRequest({
    url: `/notice-user/set-read-status`,
    method: 'post',
    data
  });
}
// 根据ID查询公告与用户关系信息（已读）
export function findNoticeUserById(id: number) {
  return configRequest({
    url: `/notice-user/${id}`,
    method: 'get'
  });
}
// 删除公告与用户关系
export function delNoticeUserById(id: number) {
  return configRequest({
    url: `/notice-user/${id}`,
    method: 'delete'
  });
}
